#!/usr/bin/env python
# Team 4067 64-bit Java Disable Tool - Disable 64-bit Java to enable SmartDashboard to run!
# Copyright (C) 2013 River Hill HS Robotics Team (Albert H.)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

import os
import sys
import shutil
import traceback
import ctypes

try:
	import win32ui
	import win32con
except:
	print "ERROR: You need to install pywin32 in order to use this program."
	print "Get it at http://sourceforge.net/projects/pywin32/ and install it."
	print "Press ENTER to exit."
	raw_input()
	sys.exit(1)

# Functions

# Windows 64-bit check - courtesy of "phobie" from http://stackoverflow.com/a/12578715
def is_windows_64bit():
    if 'PROCESSOR_ARCHITEW6432' in os.environ:
        return True
    return os.environ['PROCESSOR_ARCHITECTURE'].endswith('64')

print "SmartDashboard 64-bit Launcher"
print "==============================="
print "Copyright (C) 2013 River Hill High School Robotics Team (Albert H.)"
print "              *** FRC 4067 The Incredible Hawk *** "
print ""
# Sanity check - is this Windows?
if sys.platform != 'win32':
	print "ERROR: This tool only runs on Windows."
	print "Press ENTER to exit."
	raw_input()
	sys.exit(1)

if not is_windows_64bit():
	print "ERROR: This tool only runs on Windows 64-bit. (You are running Windows 32-bit, as detected by this program.)"
	win32ui.MessageBox("This tool only runs on Windows 64-bit. You are running Windows 32-bit, as detected by this program.", "Error - SmartDashboard 64-bit Launcher", win32con.MB_ICONERROR)
	sys.exit(1)

print "Trying to find a 32-bit Java installation..."

#if os.path.isdir("C:\Program Files (x86)\Java"):
#win32ui.MessageBox("Hello world", "Hello", win32con.MB_ICONERROR)